//
// SystemCall.h
// Usage: Declare of system call implement function
// CreateDate: 2009-05-05
// Author: MaJiuyue
//
#ifndef _SYSTEM_CALL_H_
#define _SYSTEM_CALL_H_

#include <NewLife.h>

#define SYSCALL_SBRK	0x1001

#define SYSCALL_GETPID	0x2001
#define SYSCALL_FORK	0x2002
#define SYSCALL_EXIT	0x2003
#define SYSCALL_BLOCK   0x2004
#define SYSCALL_WAKEUP  0x2005
#define SYSCALL_WAITPID 0x2006

#define SYSCALL_SEND	0x3001
#define SYSCALL_RECEIVE	0x3002

#define SYSCALL_OPEN	0x4001
#define SYSCALL_CLOSE	0x4002
#define SYSCALL_READ	0x4003
#define SYSCALL_WRITE	0x4004
#define SYSCALL_LSEEK	0x4005
#define SYSCALL_MKDEV	0x4010

#define SYSCALL_GETTIMEOFDAY	0x5001

#define SYSCALL_NL_MAPADDRESS		0x10000001
#define SYSCALL_NL_UNMAPADDRESS		0x10000002
#define SYSCALL_NL_REGISTERIRQ		0x10000003
#define SYSCALL_NL_UNREGISTERIRQ	0x10000004
#define SYSCALL_NL_FINISHREQUEST	0x10000005
#define SYSCALL_NL_SETPRIORITY		0x10000006


namespace SystemCall
{
	/* mm */
	addr_t do_sbrk(int incr);

	/* pm */
	int do_getpid();
	pid_t do_fork();
	int do_exit();
	int do_waitpid(pid_t pid);
	void do_block(pid_t pid);
	void do_wakeup(pid_t pid);

	/* ipc */
	int do_send(pid_t dst, addr_t uaddr);
	int do_receive(pid_t src, addr_t uaddr);

	/* fs */
	int do_open(regs_t *reg);
	int do_close(regs_t *reg);
	int do_read(regs_t *reg);
	int do_write(regs_t *reg);
	int do_lseek(regs_t *reg);
	int do_mkdev(regs_t *reg);

	int do_gettimeofday(regs_t *reg);

	/* NewLife */
	int do_MapAddress(regs_t *reg);
	int do_UnmapAddress(regs_t *reg);
	int do_RegisterIRQ(regs_t *reg);
	int do_UnRegisterIRQ(regs_t *reg);
	int do_FinishRequest(regs_t *reg);
	int do_SetPriority(regs_t *reg);
};

#endif

